from fastapi import APIRouter, Depends
from fastapi_jwt_auth import AuthJWT


router = APIRouter()


@router.get('/book')
def get_book(Authorize: AuthJWT = Depends()):
    # 必须登录才能访问
    Authorize.jwt_required()

    # 当前登录的用户名获取
    current_user = Authorize.get_jwt_subject()
    print(current_user)
    claims = Authorize.get_raw_jwt()        # 如果之前的token 没有存额外内容，解析是不会有的
    print(claims)
    print(claims["is_admin"])

    return {"msg": "获取成功"}

